package com.example.rabbitmq.starter.exception;

/**
 * 资源未找到异常
 * 当请求的资源不存在时抛出此异常
 *
 * @author example
 * @since 1.0.0
 */
public class ResourceNotFoundException extends RuntimeException {

    public ResourceNotFoundException(String message) {
        super(message);
    }

    public ResourceNotFoundException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * 根据资源类型和ID创建异常
     */
    public static ResourceNotFoundException of(String resourceType, Object id) {
        return new ResourceNotFoundException(String.format("%s with id '%s' not found", resourceType, id));
    }

    /**
     * 根据资源类型和条件创建异常
     */
    public static ResourceNotFoundException of(String resourceType, String condition) {
        return new ResourceNotFoundException(String.format("%s %s not found", resourceType, condition));
    }
}